package com.tcm.ucenter.service;

import cn.hutool.core.util.ObjectUtil;
import com.base.core.dozer.DozerConvert;
import com.base.genid.generator.UidGenerator;
import com.tcm.ucenter.domain.dto.UserAccountDTO;
import com.tcm.ucenter.domain.entity.UserAccount;
import com.tcm.ucenter.mapper.UserAccountMapper;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;


@DubboService(version = "0.0.1-alpha", retries = 3, timeout = 6000, delay = -1)
public class UserAccountServiceImpl implements UserAccountService {

    @Autowired
    private UserAccountMapper userAccountMapper;


    @DubboReference(version = "0.0.1-beta", group = "cached-uid", timeout = 6000, check = false, retries = 3)
    private UidGenerator uidGenerator;

    /**
     * 获得单条信息
     *
     * @param id
     * @return Doctor
     */
    @Override
    public UserAccountDTO findByUserId(Long id) {
        UserAccount userAccount = userAccountMapper.findByUserId(id);
        UserAccountDTO userAccountDTO = null;
        if (ObjectUtil.isNotEmpty(userAccount)) {
            userAccountDTO = DozerConvert.copyProperties(userAccount, UserAccountDTO.class);
        }
        return userAccountDTO;
    }

    /**
     * 永久删除
     *
     * @param id
     */
    @Override
    public void deleteById(Long id) {
        userAccountMapper.deleteById(id);
    }

    /**
     * 永久删除
     *
     * @param id
     */
    @Override
    public void deleteLogicById(Long id) {
        userAccountMapper.deleteLogicById(id);
    }

}

